package operation;
import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2024-06-04
 * Time: 21:57
 */
public class FindBooks implements IBooks{
    @Override
    public void work(BookList booklist){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的书名");
        String name = scanner.nextLine();
        int count = booklist.getUsedSize();
        for (int i = 0; i < count; i++) {
            Book book = booklist.getBook(i);
            if(book.getName().equals(name)){
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本图书");
    }
}
